package com.baturu.vin.byd.dal.dao;

import com.baturu.vin.byd.dto.BydImageDTO;
import com.baturu.vin.byd.dto.BydPartsInfoDTO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Collection;
import java.util.List;

/**
 * 比亚迪图片DAO
 * @author jiangxinlei
 * @Time 2018/1/10.
 */
public interface BydImageDAO {

    @Select({"<script>select distinct id as dataLegendId, image as imageName from byd_data_legend",
            "where id in",
            "<foreach item='item' index='index' collection='ids' open='(' separator=',' close=')'>",
            "#{item}",
            "</foreach>",
            "</script>"})
    List<BydImageDTO> queryImageInfo(@Param("ids") Collection<Long> ids);

    @Select({"<script>select distinct x, y, callout, carSystemId, dataGroupId, dataLegendId from byd_parts_hotpoints",
            "where (callout, carSystemId, dataGroupId, dataLegendId) in ",
            "<foreach item='item' index='index' collection='partsInfo' open='(' separator=',' close=')'>",
            "(#{item.callout},#{item.carSystemId},#{item.dataGroupId},#{item.dataLegendId})",
            "</foreach>",
            "</script>"})
    List<BydImageDTO> queryImagePosition(@Param("partsInfo") Collection<BydPartsInfoDTO> partsInfo);

    @Insert({"<script>insert ignore into byd_legend_image_size(width,height,imageName) values",
            "<foreach item='item' index='index' collection='dtos' open='' separator=',' close=''>",
            "(#{item.x},#{item.y},#{item.imageName})",
            "</foreach>",
            "</script>"})
    int addImageSize(@Param("dtos") Collection<BydImageDTO> dtos);

}
